﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;
using Entities;

namespace Mapping
{
    public class LoadAtomMap : ClassMap<LoadAtom>
    {
        public LoadAtomMap()
        {
            Id(x => x.Id).GeneratedBy.Identity();
            References(x => x.Allocation)
                .Column("AllocationId")
                .ForeignKey()
                .Cascade.SaveUpdate();
            Map(x => x.LoadType);
            Map(x => x.Hours);
            Map(x => x.GroupRelationType);
            References(x => x.Teacher)
                .Column("TeacherId")
                .ForeignKey()
                .Nullable()
                .Cascade.SaveUpdate();
            HasManyToMany(x => x.Groups)
                .ParentKeyColumn("LoadAtomId")
                .ChildKeyColumn("GroupId")
                .Cascade.SaveUpdate()
                .Table("GroupLoadAtom");
        }
    }
}
